<template>
  <div class="app-container">
         <el-table v-loading="loading" :data="list" >
      <el-table-column label="客户名称" align="center" prop="customerName">
         <template slot-scope="scope">
           <el-link @click="openCustomer(scope.row)" :underline="false" type="primary" >{{scope.row.customerName}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="访问类型" align="center" prop="visitType" width="160PX" >
          <template slot-scope="scope">
              <el-tag prop="visitType" v-for="(item, index) in typeOptions"     v-if="scope.row.visitType==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
      <el-table-column label="内容" align="center" prop="content" />
      <el-table-column label="联系人" align="center" prop="contactName" />
      <el-table-column label="详细地址" align="center" prop="address" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下次联系时间" align="center" prop="nextTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.nextTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      </el-table>
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
    
  </div>
</template>

<script>

import { getNewVisit } from "@/api/crm/customerVisit";

export default {
  name: "customer",
  data() {
    return {
      
      // 遮罩层
      loading: true,
      list: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      typeOptions:[],
      

    };
  },
  created() {
    this.getDicts("customer_visit_type").then((response) => {
      this.typeOptions = response.data;
    });
    
 
  },
  mounted() {
   
  },
  methods: {
    openCustomer(row){
      const customerId = row.customerId || this.ids
      this.$emit('open-customer',customerId);
      
    },
    getList(data) {
      this.loading = true;
      this.queryParams.type=data.type;
      this.queryParams.userIds=data.userIds;
      this.queryParams.deptId=data.deptId;
      getNewVisit(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    
   
    
  }
};
</script>
<style scoped>
 
</style>

